using UnityEngine;
using System.Collections;

public class WowadiusInvaderBehaviour : MonoBehaviour
{
	
	#region Private fields
	private const float MOVE_SPEED = 0.01f;
	private const float ROTATION_SPEED = 0.05f;
	//Time in second to switch the moving direction
	private const int SWITCH_DIRECTION_TIME = 2;
	
	private float _switchDirectionTimer = 0f;
    private bool _beingDestroyed = false;
	#endregion
	// Use this for initialization
	void Awake ()
	{
		//Face the player
		//transform.eulerAngles = new Vector3 (0, 0, 180);
	}

	// Update is called once per frame
	void FixedUpdate ()
	{
		//Rotate around self if still alive
        if (!_beingDestroyed)
        {
            transform.eulerAngles = new Vector3(0, 0, 180);
            transform.RotateAroundLocal(Vector3.down, ROTATION_SPEED);
        }
		
		//Update switch moving direction timer
		_switchDirectionTimer += Time.deltaTime;
        if (_switchDirectionTimer >= SWITCH_DIRECTION_TIME)
        {
            _switchDirectionTimer = 0;
            switchDirection();
        }
		
		//Moving
		transform.localPosition += new Vector3 (0, -MOVE_SPEED, 0);
	}

    void OnBeingDestroyed()
    {
        _beingDestroyed = true;
    }
	
	private void switchDirection(){
	}
}
